//
//  PaperTimerViewManager.m
//  ZYOnlineSchool
//
//  Created by 毕武侠 on 2017/3/1.
//  Copyright © 2017年 bwx. All rights reserved.
//

#import "PaperTimerViewManager.h"
#import "PaperMessageView.h"

@interface PaperTimerViewManager ()

@property (nonatomic, strong) PaperMessageView *view;
@property (nonatomic, strong, readwrite) RACSignal *hiddenSignal;      // 隐藏Signal
@property (nonatomic, strong) NSMutableAttributedString *restText;         // 休息一下
@property (nonatomic, strong) NSMutableAttributedString *suspendText;      // 暂停

@end

@implementation PaperTimerViewManager
@dynamic view;

- (void)setupConfigure {
    self.view = [[PaperMessageView alloc] initWithTitle:self.restText];
    self.view.hidden = YES;
    if (self.superView) {
        [self.superView addSubview:self.view];
    }

    self.hiddenSignal = [self.view getSignalWithDictionary:@{@"action" : @"hidden"}];
}

// [[NSDate date] stringWithFormat:@"YYYY-MM-dd HH:mm:ss"];
#pragma mark - setter

- (void)setRestSignal:(RACSignal *)restSignal {
    _restSignal = restSignal;
    
    [_restSignal subscribeNext:^(id x) {
        self.view.hidden = NO;
    }];
}

#pragma mark - getter

- (NSMutableAttributedString *)restText {
    if (_restText == nil) {
        _restText = [[NSMutableAttributedString alloc] initWithString:@"休息一下\n\n"];
        _restText.font  = [UIFont systemFontOfSize:20];
        
        NSMutableAttributedString *content = [[NSMutableAttributedString alloc] initWithString:@"点击任意位置继续"];
        content.font = [UIFont systemFontOfSize:17];
        [_restText appendAttributedString:content];
    }
    return _restText;
}

- (NSMutableAttributedString *)suspendText {
    if (_suspendText == nil) {
        _suspendText = [[NSMutableAttributedString alloc] initWithString:@"您已长时间没有操作，练习自动暂停\n\n点击任意位置继续"];
        _suspendText.font  = [UIFont systemFontOfSize:17];
    }
    return _suspendText;
}

@end
